<extend name="Public/base"/>
<block name="content">
<h3 class="col-md-8"><present name="data">[ <{$data.title}> ] 子</present>菜单管理</h3>
<div class="col-md-4">
	<div class="input-group mb-lg">
    	<input type="text" name="title" class="form-control" value="<{:I('title')}>" placeholder="请输入菜单名称">
    	<span class="input-group-addon">    		
        	<a class="fa-search fa" href="javascript:;" id="search" url="__SELF__"></a> 
    	</span>
	</div>
</div>

<div class="row">
    <div class="col-lg-12">
    	<div class="panel panel-default">
       		<div class="panel-heading ">菜单列表
       			<div class="btn-group pull-right">
        			<a class="btn btn-labeled btn-success" href="<{:U('add',array('pid'=>I('get.pid',0)))}>">新 增</a>
        			<button class="btn btn-labeled btn-danger ajax-post confirm" url="<{:U('del')}>" target-form="ids">删 除</button>
        			<a class="btn btn-labeled  btn-success" href="<{:U('import',array('pid'=>I('get.pid',0)))}>">导 入</a>
        			<button class="btn btn-labeled btn-danger list_sort" url="<{:U('sort',array('pid'=>I('get.pid',0)),'')}>">排序</button>
	         	</div>      			
       		</div>
    		<div class="table-responsive">
                <form class="ids">
                    <table class="table table-striped table-bordered table-hover"> 
                        <thead>
                            <tr>
                                <th style="width: 5%" class="check-all">
                          			<div data-toggle="tooltip" data-title="全选" class="checkbox c-checkbox">
                             		<label>
                                		<input type="checkbox">
                                		<span class="fa fa-check"></span>
                             		</label>
                          			</div>
                       			</th> 
                                <th>ID</th>
                                <th>名称</th>
                                <th>上级菜单</th>
                                <th>分组</th>
                                <th>URL</th>
                                <th>排序</th>
                                <!--th>仅开发者模式显示</th-->
                                <th>隐藏</th>
                                <th class='text-center'>操作</th>
                            </tr>
                        </thead>
                        <tbody>
        				<notempty name="list">
                        <volist name="list" id="menu">
                            <tr>
                            	<td>
                          			<div class="checkbox c-checkbox">
                             		<label>
                                	<input type="checkbox" value="<{$menu.id}>" name="id[]">
                                	<span class="fa fa-check"></span>
                             		</label>
                          			</div>
                       			</td>  
                                
                                <td><{$menu.id}></td>
                                <td>
                                    <a href="<{:U('index?pid='.$menu['id'])}>"><{$menu.title}></a>
                                </td>
                                <td><{$menu.up_title|default='无'}></td>
                                <td><{$menu.group}></td>
                                <td><{$menu.url}></td>
                                <td><{$menu.sort}></td>
                                <!--td>
                                    <a href="<{:U('toogleDev',array('id'=>$menu['id'],'value'=>abs($menu['is_dev']-1)))}>" class="ajax-get">
                                    <{$menu.is_dev_text}>
                                    </a>
                                </td-->
                                <td>
                                    <a href="<{:U('toogleHide',array('id'=>$menu['id'],'value'=>abs($menu['hide']-1)))}>" class="ajax-get">
                                    <{$menu.hide_text}>
                                    </a>
                                </td>
                                <td  class='text-center'>
                                	<a class="btn btn-labeled btn-sm " href="<{:U('edit?id='.$menu['id'])}>"><em class="fa fa-edit"></em></a>
	                            	<a class="btn btn-labeled btn-sm " href="<{:U('del?id='.$menu['id'])}>"><em class="fa fa-times"></em></a>
                                </td>
                            </tr>
                        </volist>
        				<else/>
        				<td colspan="10" class="text-center">暂时还没有内容! </td>
        				</notempty>
                        </tbody>
                    </table>                
	        		<!-- 结束 表格 -->
	        		<div class="panel-footer">
	        			<div class="row">
							<ul class="pagination">
							<{$_page}>
							</ul>
						 </div>
	                </div>
	        	</form> 
    		</div>    		
    	</div>
    </div>
</div>
</block>

<block name="script">
    <script type="text/javascript">
    	highlight_subnav("<{:U('Config/group')}>","<{:U('Menu/index')}>");
        $(function() {
            //搜索功能
            $("#search").click(function() {
                var url = $(this).attr('url');
                var query = $('.search-form').find('input').serialize();
                query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
                query = query.replace(/^&/g, '');
                if (url.indexOf('?') > 0) {
                    url += '&' + query;
                } else {
                    url += '?' + query;
                }
                window.location.href = url;
            });
            //回车搜索
            $(".search-input").keyup(function(e) {
                if (e.keyCode === 13) {
                    $("#search").click();
                    return false;
                }
            });
            //导航高亮
            $('#head-menu').find('a[href="<{:U('Config/index')}>"]').closest('li').addClass('current');
            //点击排序
        	$('.list_sort').click(function(){
        		var url = $(this).attr('url');
        		var ids = $('.ids:checked');
        		var param = '';
        		if(ids.length > 0){
        			var str = new Array();
        			ids.each(function(){
        				str.push($(this).val());
        			});
        			param = str.join(',');
        		}

        		if(url != undefined && url != ''){
        			window.location.href = url + '/ids/' + param;
        		}
        	});
        });
    </script>
</block>